﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using soho.Library;
public partial class CRMLogin : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!Page.IsPostBack)
        {
            lblMsg.Text = string.Empty;
        }
    }
    
    protected void btnSignIn_Click(object sender, EventArgs e)
    {
        //Login
        Session[GeneralUsage.CurrentUser] = null;
        int result = CustomerUtl.Login(txtUserName.Text.Trim(),sohoUtility.EncodePassword(txtPassword.Text.Trim()));
        if (result == 0)
        {
            lblMsg.Text = GetLocalResourceObject("lblMsg.Text.Welcome").ToString();
            Session[GeneralUsage.CurrentUser] = CustomerUtl.GetCustomer(txtUserName.Text.Trim());
            lblPassword.Visible = lblUserName.Visible = false;
            txtUserName.Visible = txtPassword.Visible = false;
            btnSignIn.Visible = btnSignUp.Visible = false;
        }
        else if (result == 1)
        {
            lblMsg.Text = GetLocalResourceObject("lblMsg.Text.WrongUserName").ToString();
        }
        else if (result == 2)
        {
            lblMsg.Text = GetLocalResourceObject("lblMsg.Text.WrongPassword").ToString();
        }
        
    }
    protected void btnSignUp_Click(object sender, EventArgs e)
    {
        Response.Redirect("CRMSignUp.aspx");
    }
}